package com.javahash.spring.controller;

import com.javahash.spring.service.MongoExchangeRates;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
public class ExchangeRatesController {

    /**
     * Returns a String object that contains all the currencies and their exchange rates as JSON data.
     *
     * @return the map of currencies and their exchange rates as a String JSON
     */


    @Autowired
    MongoExchangeRates MongoExchangeRates;

    @RequestMapping("/rate")
    @ResponseBody
    public String rate() {

        return MongoExchangeRates.getLatestRates();

    }

}
